def longest_palindrome(s):
    """
        找到字符串中最长的回文子串
        :param s: 输入字符串，例如 "babad"
        :return: 最长的回文子串
        """
    if not s:
        return ""

    def expand_around_center(left, right):
        while left >= 0 and right < len(s) and s[left] == s[right]:
            left -= 1
            right += 1
        return s[left + 1:right]

    longest = ""
    for i in range(len(s)):
        # 奇数长度的回文子串
        palindrome_odd = expand_around_center(i, i)
        # 偶数长度的回文子串
        palindrome_even = expand_around_center(i, i + 1)

        if len(palindrome_odd) > len(longest):
            longest = palindrome_odd
        if len(palindrome_even) > len(longest):
            longest = palindrome_even

    return len(longest)


if __name__ == '__main__':
    print(longest_palindrome("a"))
    print(longest_palindrome("aa"))
    print(longest_palindrome("baa"))
    print(longest_palindrome("aab"))
    print(longest_palindrome("abcdefghba"))
    print(longest_palindrome("baablkj12345432133d"))
